package com.skyjing.askit.dsl.seekbar

import android.widget.SeekBar

class SeekBarChangeListenerDsl : SeekBar.OnSeekBarChangeListener {
    private var onProgressChanged: ((seekBar: SeekBar?, progress: Int, fromUser: Boolean) -> Unit)? =
        null
    private var onStartTrackingTouch: ((seekBar: SeekBar?) -> Unit)? = null
    private var onStopTrackingTouch: ((seekBar: SeekBar?) -> Unit)? = null

    override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
        onProgressChanged?.invoke(seekBar , progress , fromUser)
    }

    override fun onStartTrackingTouch(seekBar: SeekBar?) {
        onStartTrackingTouch?.invoke(seekBar)
    }

    override fun onStopTrackingTouch(seekBar: SeekBar?) {
        onStopTrackingTouch?.invoke(seekBar)
    }

    fun onProgressChanged(onProgressChanged : (seekBar: SeekBar?, progress: Int, fromUser: Boolean) ->Unit) {
        this.onProgressChanged = onProgressChanged
    }

    fun onStartTrackingTouch(onStartTrackingTouch : (seekBar: SeekBar?) -> Unit) {
        this.onStartTrackingTouch = onStartTrackingTouch
    }

    fun onStopTrackingTouch(onStopTrackingTouch : (seekBar: SeekBar?) -> Unit) {
        this.onStopTrackingTouch = onStopTrackingTouch
    }
}